<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html lang="zh">
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path;
%>
<head>
    <meta charset="utf-8" />
    <title>保险代理后台管理系统</title>
    <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" name="viewport" />
    <jsp:include page="../common/header.jsp"></jsp:include>
    <%@include file="../common/taglib.jsp"%>

    <!-- ================== 单独作用于本页表格td ================== -->
    <style>
    </style>
    <!-- ================== 单独作用于本页表格td ================== -->

</head>
<body>
<!-- begin #page-loader -->
<div id="page-loader" class="fade in"><span class="spinner"></span></div>
<!-- end #page-loader -->

<!-- begin #page-container -->
<div id="page-container" class="fade page-sidebar-fixed page-header-fixed">
    <jsp:include page="../common/top.jsp"/>

    <!-- begin #sidebar -->
    <jsp:include page="../common/sitebar.jsp"/>
    <div class="sidebar-bg"></div>
    <!-- end #sidebar -->
    <!-- begin #content -->
        <div id="content" class="content">
            <!-- begin row -->
            <div class="row">
                <div class="col-md-12">
                    <ul id ="repayTabs" class="nav nav-tabs">
                        <shiro:hasPermission name="已退保订单-保险公司">
                        <li id="firstTab" class="active"><a href="#default-tab-1" data-toggle="tab" onclick="changeUrl(1)">保险公司</a></li>
                        </shiro:hasPermission>
                        <shiro:hasPermission name="已退保订单-渠道">
                        <li id="secondTab" class=""><a href="#default-tab-2" data-toggle="tab" onclick="changeUrl(2)">渠道</a></li>
                        </shiro:hasPermission>
                        <li class="hidden" id="detail"><a href="#default-tab-3"  data-toggle="tab" >保单详情</a></li>

                        <shiro:hasPermission name="已退保保险公司列表-下载">
                        <li class="link-down">
                        <span onclick="openModel(1)" id="down">
                          <i class="fa fa-download fa-2"></i>下载列表
                         </span>
                        </li>
                        </shiro:hasPermission>

                        <shiro:hasPermission name="已退保渠道列表-下载">
                            <li class="link-down hidden">
                        <span onclick="openModel(2)" id="down1">
                          <i class="fa fa-download fa-2"></i>下载列表
                         </span>
                            </li>
                        </shiro:hasPermission>
                    </ul>
                    <div class="tab-content">
                        <div class="tab-pane fade active in" id="default-tab-1">
                            <div class="panel-body">
                                <form class="form-horizontal">

                                    <div class="form-group">
                                        <label class="col-md-1 control-label" style="width: 110px;">保险公司:</label>
                                        <div class="col-md-2">
                                            <select id="insyrerIdSerch" class="form-control">
                                                <option value="">全部</option>
                                                <c:forEach items="${insurerList}" var="isl">
                                                    <option value="${isl.tid}">${isl.name}</option>
                                                </c:forEach>
                                            </select>
                                        </div>

                                        <label class="col-md-1 control-label">保单号:</label>
                                        <div class="col-md-2">
                                            <input type="text" id="ordNumSerch"  class="form-control" placeholder="保单号" />
                                        </div>
                                        <label class="col-md-1 control-label">出单日期:</label>
                                        <div class="col-md-3">
                                            <div class="input-group input-daterange">
                                                <input type="text" class="form-control datepicker-default" id="dateIssuanceStartSerch" placeholder="开始日期" />
                                                <span class="input-group-addon">至</span>
                                                <input type="text" class="form-control datepicker-default" id="dateIssuanceEndSerch" placeholder="结束日期"/>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-md-1 control-label" style="width: 110px;">渠道:</label>
                                        <div class="col-md-2">
                                            <input type="hidden" name="channelIdSerch" id="channelIdSerch">
                                            <input type="text" id="channelNameSerch" name="channelNameSerch" data-toggle="dropdown"  class="form-control dropdown-toggle" placeholder="渠道" />
                                            <ul id="chs" class="dropdown-menu" style="max-height: 200px;overflow: auto;margin-left: 15px;">
                                            </ul>
                                        </div>

                                        <label class="col-md-1 control-label">退保日期:</label>
                                        <div class="col-md-3">
                                            <div class="input-group input-daterange">
                                                <input type="text" class="form-control datepicker-default" id="surrenderDateStartSerch" placeholder="开始日期" />
                                                <span class="input-group-addon">至</span>
                                                <input type="text" class="form-control datepicker-default" id="surrenderDateEndSerch" placeholder="结束日期"/>
                                            </div>
                                        </div>
                                        <div class="col-md-3">
                                            <button type="button" onclick="search1()" class="btn btn-primary m-r-5 m-b-5">查询</button>
                                           <%-- <button type="button" onclick="download1s()" class="btn btn-primary m-r-5 m-b-5">下载</button>--%>
                                        </div>
                                    </div>
                                </form>
                            <div class="table-responsive" >
                                <table id="insurerTable1" class="table table-striped table-bordered" style= "word-break:break-all;word-wrap:break-word">
                                    <thead>
                                    <tr>
                                        <th width="6%">保单号</th>
                                        <th width="6%">付款主体</th>
                                        <th width="6%">保险公司</th>
                                        <th width="6%">渠道</th>
                                        <th width="6%">渠道联系电话</th>
                                        <th width="6%">险种</th>
                                        <th width="6%">被保险人</th>
                                        <th width="6%">被保险人证件号</th>
                                       <%-- <th width="6%">投保人</th>--%><%--//没有--%>
                                        <th width="6%">车牌号</th>
                                        <th width="6%">车主姓名</th><%--//没有--%>
                                        <th width="6%">商业保险费(元)</th>
                                        <th width="6%">交强保险费(元)</th>
                                        <th width="6%">车船税(元)</th>
                                        <th width="6%">全保费(元)</th>
                                        <th width="6%">下单日期</th><%--//没有--%>
                                        <th width="6%">起保日期</th>
                                        <th width="6%">跟单员</th><%--//没有--%>
                                        <th width="6%">退保日期</th>
                                        <th width="6%">退保扣除手续费(元)</th>
                                        <th width="6%">退保核对日期</th><%--//没有--%>
                                        <th width="6%">操作</th>
                                    </tr>
                                    </thead>
                                </table>
                            </div>
                        </div>
                    </div>
                        <div class="tab-pane fade" id="default-tab-2">
                            <div class="panel-body">
                                <form class="form-horizontal">

                                    <div class="form-group">
                                        <label class="col-md-1 control-label" style="width: 110px;">保险公司:</label>
                                        <div class="col-md-2">
                                            <select id="insyrerIdCSerch" class="form-control">
                                                <option value="">全部</option>
                                                <c:forEach items="${insurerList}" var="isl">
                                                    <option value="${isl.tid}">${isl.name}</option>
                                                </c:forEach>
                                            </select>
                                        </div>

                                        <label class="col-md-1 control-label">保单号:</label>
                                        <div class="col-md-2">
                                            <input type="text" id="ordNumCSerch"  class="form-control" placeholder="保单号" />
                                        </div>
                                        <label class="col-md-1 control-label">出单日期:</label>
                                        <div class="col-md-3">
                                            <div class="input-group input-daterange">
                                                <input type="text" class="form-control datepicker-default" id="dateIssuanceStartCSerch" placeholder="开始日期" />
                                                <span class="input-group-addon">至</span>
                                                <input type="text" class="form-control datepicker-default" id="dateIssuanceEndCSerch" placeholder="结束日期"/>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-md-1 control-label" style="width: 110px;">渠道:</label>
                                        <div class="col-md-2">
                                            <input type="hidden" name="channelIdCSerch" id="channelIdCSerch">
                                            <input type="text" id="channelNameCSerch" name="channelNameCSerch" data-toggle="dropdown"  class="form-control dropdown-toggle" placeholder="渠道" />
                                            <ul id="chc" class="dropdown-menu" style="max-height: 200px;overflow: auto;margin-left: 15px;">
                                            </ul>
                                        </div>

                                        <label class="col-md-1 control-label">退保日期:</label>
                                        <div class="col-md-3">
                                            <div class="input-group input-daterange">
                                                <input type="text" class="form-control datepicker-default" id="surrenderDateStartCSerch" placeholder="开始日期" />
                                                <span class="input-group-addon">至</span>
                                                <input type="text" class="form-control datepicker-default" id="surrenderDateEndCSerch" placeholder="结束日期"/>
                                            </div>
                                        </div>
                                        <div class="col-md-3">
                                            <button type="button" onclick="search2()" class="btn btn-primary m-r-5 m-b-5">查询</button>
                                           <%-- <button type="button" onclick="download2()" class="btn btn-primary m-r-5 m-b-5">下载</button>--%>
                                        </div>
                                    </div>
                                </form>
                            <div class="table-responsive" >
                                <table id="channelTable1" class="table table-striped table-bordered" style= "word-break:break-all;word-wrap:break-word">
                                    <thead>
                                    <tr>
                                        <th width="6%">保单号</th>
                                        <th width="6%">付款主体</th>
                                        <th width="6%">保险公司</th>
                                        <th width="6%">渠道</th>
                                        <th width="6%">渠道联系电话</th>
                                        <th width="6%">险种</th>
                                        <th width="6%">被保险人</th>
                                        <th width="6%">被保险人证件号</th>
                                        <%--<th width="6%">投保人</th>--%>
                                        <th width="6%">车牌号</th>
                                        <th width="6%">商业保险费(元)</th>
                                        <th width="6%">交强保险费(元)</th>
                                        <th width="6%">车船税(元)</th>
                                        <th width="6%">全保费(元)</th>
                                        <th width="6%">开单日期</th>
                                       <%-- <th width="6%">保险公司收保费日期</th>--%>
                                        <th width="6%">起保日期</th>
                                        <th width="6%">渠道返点(%)</th>
                                        <%--<th width="6%">商业险点位</th>
                                        <th width="6%">交强险点位</th>--%>
                                        <th width="6%">渠道返佣费</th>
                                        <th width="6%">应收保费(元)</th>
                                        <th width="6%">实收保费(元)</th>
                                        <th width="6%">渠道账期到期日</th>
                                        <th width="6%">退保日期</th>
                                        <th width="6%">退保应扣除渠道佣金(元)</th>
                                        <th width="6%">退保渠道应还保费(元)</th>
                                        <th width="6%">渠道退保结算金额(元)</th>
                                        <th width="6%">退保结算日期</th>
                                        <th width="6%">跟单员</th>
                                        <th width="6%">操作</th>
                                    </tr>
                                    </thead>
                                </table>
                            </div>
                        </div>
                    </div>
                        <div id="default-tab-3" class="tab-pane fade ">
                            <div id="iframeParent">
                                <iframe width="100%" height="100%" frameborder="0" id="iframe" scrolling="no"></iframe>
                            </div>
                        </div>
                </div>
            </div>
        </div>
            <%--提示框--%>
            <div class="modal fade" id="modal-dialog"  tabindex="-1" role="dialog" style="z-index: 999999">
                <input type="hidden" name="type" id="typee">
                <div class="modal-dialog modal-sm">

                    <div class="modal-content">
                        <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                            <h4 class="modal-title">温馨提示</h4>
                        </div>
                        <div class="modal-body" id="me">
                        </div>
                        <div class="modal-footer">
                            <a href="javascript:;" onclick="doSomeThing()" class="btn btn-sm btn-primary">确定</a>
                            <a href="javascript:;" class="btn btn-sm btn-default" data-dismiss="modal">取消</a>
                        </div>
                    </div>
                </div>
            </div>

        <!-- end row -->
        <div class="modal fade" id="insurer-subInfo">
            <div class="modal-dialog">
                <div class="modal-content">
                    <form role="form" action="/insurer/add" method="post" class="form-horizontal form-bordered" data-parsley-validate="true">

                        <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                            <h4 class="modal-title">退保核对</h4>
                        </div>
                        <div class="modal-body">
                            <div class="form-group">
                                <label class="control-label col-md-4 col-sm-4">退保保险公司扣除手续费:</label>
                                <div class="col-md-6 col-sm-6">
                                    <input class="form-control" type="text" name="name" data-parsley-required="true"
                                           data-parsley-required-message="不能为空" />
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="control-label col-md-4 col-sm-4">退保应扣除渠道佣金:</label>
                                <div class="col-md-6 col-sm-6">
                                    <input class="form-control" type="text" name="name" data-parsley-required="true"
                                           data-parsley-required-message="不能为空" />
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="control-label col-md-4 col-sm-4">退保渠道应还保费:</label>
                                <div class="col-md-6 col-sm-6">
                                    <input class="form-control" type="text" name="name" data-parsley-required="true"
                                           data-parsley-required-message="不能为空" />
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="control-label col-md-4 col-sm-4">起保日期:</label>
                                <div class="col-md-6 col-sm-6">
                                    <input class="form-control" type="text" name="name" data-parsley-required="true"
                                           data-parsley-required-message="不能为空" />
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="control-label col-md-4 col-sm-4">退保日期:</label>
                                <div class="col-md-6 col-sm-6">
                                    <input class="form-control" type="text" name="name" data-parsley-required="true"
                                           data-parsley-required-message="不能为空" />
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="control-label col-md-4 col-sm-4">备注:</label>
                                <div class="col-md-6 col-sm-6">
                                    <textarea class="form-control" id="message" name="message" rows="4" data-parsley-range="[20,200]" placeholder="Range from 20 - 200" data-parsley-id="0066"></textarea>
                                </div>
                            </div>
                        </div>
                        <div class="modal-footer">
                            <a href="javascript:;" class="btn btn-sm btn-white" data-dismiss="modal">取消</a>
                            <a href="javascript:;" class="btn btn-sm btn-success">提交</a>
                        </div>
                    </form>
                </div>
            </div>
        </div>

        <div class="modal fade" id="channel-subInfo">
            <div class="modal-dialog">
                <div class="modal-content">
                    <form class="form-horizontal">
                        <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                            <h4 class="modal-title">渠道退保结算</h4>
                        </div>
                        <div  class="modal-body">
                            当前填写内容未提交，确认取消？
                        </div>
                        <div class="modal-footer">
                            <a href="javascript:;" class="btn btn-sm btn-white" data-dismiss="modal">取消</a>
                            <a href="javascript:;" class="btn btn-sm btn-success">确定</a>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
    <jsp:include page="../common/footer.jsp"/>
        <script>
            var dic = new Array();
            <c:forEach items="${dictionary}" var="d">
            var sa = [];
            sa[0]="${d.riskKey}";
            sa[1]= "${d.riskValue}";
            dic.push(sa);
            </c:forEach>
        $(document).ready(function() {
            App.init();
            TableManageFixedHeader.init();
            $('.datepicker-default').datepicker({
                language: 'zh-CN',//显示中文
                format: 'yyyy-mm-dd',//显示格式
                minView: "month",//设置只显示到月份
                initialDate: new Date(),//初始化当前日期
                autoclose: true,//选中自动关闭
                todayBtn: 'linked'//显示今日按钮
            });
            $('.selectpicker').selectpicker({
                style: 'btn-white',
                size: 5
            });

        });
       /* function insurerShow(amt1,amt2,amt3,date1,date2,tid,ctid,type1,type2) {
            $("#amt1").val(amt1);
            $("#amt2").val(amt2);
            $("#amt3").val(amt3);
            $("#date1").val(date1.substring(0,10));
            $("#date2").val(date2.substring(0,10));
            $("#iTid").val(tid);
            $("#iCapitalTid").val(ctid);
            $("#iOpponent").val(type1);
            $("#iTradeType").val(type2);
            $("#insurer-subInfo").modal('show');
        }
        function channelShow(date1,amt1,amt2,tid,ctid,status,type1,type2) {
            $("#cAmt1").val(amt1);
            $("#cAmt2").val(amt2);
            var amt = parseFloat(amt2)+parseFloat(amt1);
            $("#cAmt3").val(amt);
            $("#cDate1").val(date1.substring(0,10));
            $("#cTid").val(tid);
            $("#cCapitalTid").val(ctid);
            $("#cOpponent").val(type1);
            $("#cTradeType").val(type2);
            $("#capitalSourcr").html("");
            if(7==status){
                $("#capitalSourcr").append("<option value='1'>正常结算</option>");
                $("#capitalSourcr").append("<option value='2'>保证金</option>");
            }else{
                $("#capitalSourcr").append("<option value='1'>正常结算</option>");
            }
            $("#channel-subInfo").modal('show');
        }*/
        var table1;
        $(document).ready(function() {
            table1 = $("#insurerTable1").DataTable({
                "pagingType": "simple_numbers",//设置分页控件的模式
                searching: false,//屏蔽datatales的查询框
                aLengthMenu:[15],//设置一页展示10条记录
                "bLengthChange": false,//屏蔽tables的一页展示多少条记录的下拉列表
                "ordering": false,
                "oLanguage": {  //对表格国际化
                    "sLengthMenu": "每页显示 _MENU_条",
                    "sZeroRecords": "无匹配结果，请更换筛选条件再试",
                    //  "sProcessing": "&lt;img src=’./loading.gif’ /&gt;",
                    "sInfo": "当前第 _START_ - _END_ 条　共计 _TOTAL_ 条",
                    "sInfoEmpty": "当前第 0 - 0 条　共计 0 条",
                    "sInfoFiltered": "(从 _MAX_ 条记录中过滤)",
                    "sSearch": "搜索：",
                    "oPaginate": {
                        "sFirst": "首页",
                        "sPrevious": "前一页",
                        "sNext": "后一页",
                        "sLast": "尾页"

                    }
                },
                //"processing": true, //打开数据加载时的等待效果
                "serverSide": true,//打开后台分页
               /* "order": [[ 5, "desc" ]],*/
                "ajax": {
                    "url": "/repay/queryInsurerData",
                    "dataSrc": "aaData",
                    "data": function ( d ) {
                        var insyrerId = $('#insyrerIdSerch').val();
                        var ordNum = $('#ordNumSerch').val();
                        var channelId = $('#channelIdSerch').val();
                        var dateIssuanceStart = $('#dateIssuanceStartSerch').val();
                        var dateIssuanceEnd = $('#dateIssuanceEndSerch').val();
                        var surrenderDateStart = $('#surrenderDateStartSerch').val();
                        var surrenderDateEnd = $('#surrenderDateEndSerch').val();
                        //添加额外的参数传给服务器
                        d.capitalStatus = 5;
                        d.insyrerId = insyrerId;
                        d.ordNum = ordNum;
                        d.channelId = channelId;
                        d.dateIssuanceStart = dateIssuanceStart;
                        d.dateIssuanceEnd = dateIssuanceEnd;
                        d.surrenderDateStart = surrenderDateStart;
                        d.surrenderDateEnd = surrenderDateEnd;
                    }
                },
                "columns": [
                   /* { "data": "ordNum","defaultContent": "--","bSortable": false}*/
                    {
                        "bSortable": false,
                        "defaultContent": '--',
                        "render": function (data, type, row, meta) {
                            var tids = row.ordNum;
                            return "<a href='#default-tab-3' data-toggle='tab' onclick='showOrderInfo("+row.tid+")'>"+tids+"</a>";
                        }
                    },
                    { "data": "paySubject" ,"defaultContent": "--","bSortable": false},
                    { "data": "insyrerName","defaultContent": "--","bSortable": false},
                    { "data": "channelPName","defaultContent": "--","bSortable": false},
                    { "data": "channelPhone" ,"defaultContent": "--","bSortable": false},
                    { "data": "typeInsurance" ,"defaultContent": "--","bSortable": false},
                    { "data": "insurant" ,"defaultContent": "--","bSortable": false},
                    { "data": "orgIdCode" ,"defaultContent": "--","bSortable": false},
                  /*  { "data": "applicant" ,"defaultContent": "--","bSortable": false},*/
                    { "data": "plateNum" ,"defaultContent": "--","bSortable": false},
                    { "data": "carOwner" ,"defaultContent": "--","bSortable": false},
                    { "data": "mercialPremium" ,"defaultContent": "--",sClass: "text-right","bSortable": false},
                    { "data": "pulsoryPremium" ,"defaultContent": "--",sClass: "text-right","bSortable": false},
                    { "data": "vechcleVesselTax" ,"defaultContent": "--",sClass: "text-right","bSortable": false},
                    { "data": "allPremium" ,"defaultContent": "--",sClass: "text-right","bSortable": false},
                    { "data": "createDate" ,"defaultContent": "--","bSortable": false},
                    { "data": "datePolicy" ,"defaultContent": "--","bSortable": false},
                    { "data": "salemanName" ,"defaultContent": "--","bSortable": false},
                    { "data": "surrenderDate" ,"defaultContent": "--","bSortable": false},
                    { "data": "payInsurerAmt","defaultContent": "--",sClass: "text-right" ,"bSortable": false},
                    { "data": "checkDate" ,"defaultContent": "--","bSortable": false}
                ],

                "columnDefs" : [ {
                    // 定义操作列,######以下是重点########
                    "targets" : 20,//是操作按钮目标列
                    "data" : null,
                    "render" : function(data, type,row) {
                        var id = '"' + row.tid + '"';
                        var html = "";
                        html += "<a href='#default-tab-3' data-toggle='tab' onclick='showOrderInfo("+row.tid+")'  class='btn-link'>查看详情</a>"
                        return html;
                    }
                },{
                        // 定义操作列,######以下是重点########
                        "targets" : 5,//是操作按钮目标列
                        "data" : null,
                        "render" : function(data, type,row) {
                            var type =  row.typeInsurance;
                            var html = "商业险";
                            if('0'==type){
                                html = "交强险";
                            }
                            return html;
                        }
                    },{
                    // 定义操作列,######以下是重点########
                    "targets" : 1,//是操作按钮目标列
                    "data" : null,
                    "render" : function(data, type,row) {
                        var type =  ""+row.paySubject;
                        var html = "--";
                        for(var i=0;i<dic.length;i++){
                            var dics = ""+dic[i][0];
                            if(type==dics){
                                html = dic[i][1];
                            }
                        }
                        return html;
                    }
                },{
                    // 定义操作列,######以下是重点########
                    "targets" : 3,//是操作按钮目标列
                    "data" : null,
                    "render" : function(data, type,row) {
                        var type =  row.channelType;
                        var html =  row.channelCName;
                        if('1'==type){
                            html = row.channelPName;
                        }
                        return html;
                    }
                }]

            } );
        } );
        var table2;
        $(document).ready(function() {
            table2 = $("#channelTable1").DataTable( {
                "pagingType": "simple_numbers",//设置分页控件的模式
                searching: false,//屏蔽datatales的查询框
                aLengthMenu:[15],//设置一页展示10条记录
                "bLengthChange": false,//屏蔽tables的一页展示多少条记录的下拉列表
                "ordering": false,
                "oLanguage": {  //对表格国际化
                    "sLengthMenu": "每页显示 _MENU_条",
                    "sZeroRecords": "无匹配结果，请更换筛选条件再试",
                    //  "sProcessing": "&lt;img src=’./loading.gif’ /&gt;",
                    "sInfo": "当前第 _START_ - _END_ 条　共计 _TOTAL_ 条",
                    "sInfoEmpty": "当前第 0 - 0 条　共计 0 条",
                    "sInfoFiltered": "(从 _MAX_ 条记录中过滤)",
                    "sSearch": "搜索：",
                    "oPaginate": {
                        "sFirst": "首页",
                        "sPrevious": "前一页",
                        "sNext": "后一页",
                        "sLast": "尾页"

                    }
                },
                //"processing": true, //打开数据加载时的等待效果
                "serverSide": true,//打开后台分页
                /*"order": [[ 5, "desc" ]],*/
                "ajax": {
                    "url": "/repay/queryInsurerData",
                    "dataSrc": "aaData",
                    "data": function ( d ) {
                        var insyrerId = $('#insyrerIdCSerch').val();
                        var ordNum = $('#ordNumCSerch').val();
                        var channelId = $('#channelIdCSerch').val();
                        var dateIssuanceStart = $('#dateIssuanceStartCSerch').val();
                        var dateIssuanceEnd = $('#dateIssuanceEndCSerch').val();
                        var surrenderDateStart = $('#surrenderDateStartCSerch').val();
                        var surrenderDateEnd = $('#surrenderDateEndCSerch').val();
                        //添加额外的参数传给服务器
                        d.capitalStatus = 5;
                        d.insyrerId = insyrerId;
                        d.ordNum = ordNum;
                        d.channelId = channelId;
                        d.dateIssuanceStart = dateIssuanceStart;
                        d.dateIssuanceEnd = dateIssuanceEnd;
                        d.surrenderDateStart = surrenderDateStart;
                        d.surrenderDateEnd = surrenderDateEnd;
                    }
                },
                "columns": [
                    /*{ "data": "ordNum","defaultContent": "--","bSortable": false},*/
                    {
                        "bSortable": false,
                        "defaultContent": '--',
                        "render": function (data, type, row, meta) {
                            var tids = row.ordNum;
                            return "<a href='#default-tab-3' data-toggle='tab' onclick='showOrderInfo("+row.tid+")'>"+tids+"</a>";
                        }
                    },
                    { "data": "paySubject" ,"defaultContent": "--","bSortable": false},
                    { "data": "insyrerName","defaultContent": "--","bSortable": false},
                    { "data": "channelPName","defaultContent": "--","bSortable": false},
                    { "data": "channelPhone" ,"defaultContent": "--","bSortable": false},
                    { "data": "typeInsurance" ,"defaultContent": "--","bSortable": false},
                    { "data": "insurant" ,"defaultContent": "--","bSortable": false},
                    { "data": "orgIdCode" ,"defaultContent": "--","bSortable": false},
                   /* { "data": "applicant" ,"defaultContent": "--","bSortable": false},*/
                    { "data": "plateNum" ,"defaultContent": "--","bSortable": false},
                    { "data": "mercialPremium" ,"defaultContent": "--",sClass: "text-right","bSortable": false},
                    { "data": "pulsoryPremium" ,"defaultContent": "--",sClass: "text-right","bSortable": false},
                    { "data": "vechcleVesselTax" ,"defaultContent": "--",sClass: "text-right","bSortable": false},
                    { "data": "allPremium" ,"defaultContent": "--",sClass: "text-right","bSortable": false},
                    { "data": "dateIssuance" ,"defaultContent": "--","bSortable": false},
                    { "data": "datePolicy" ,"defaultContent": "--","bSortable": false},
                    { "data": "channelRebate" ,"defaultContent": "--","bSortable": false},
                    { "data": "insureMustRebateAmt","defaultContent": "--",sClass: "text-right" ,"bSortable": false},
                    { "data": "insureMustPremium","defaultContent": "--",sClass: "text-right" ,"bSortable": false},
                    { "data": "insureRealPremium","defaultContent": "--",sClass: "text-right" ,"bSortable": false},
                    { "data": "insyrerMaturityDate" ,"defaultContent": "--","bSortable": false},
                    { "data": "surrenderDate" ,"defaultContent": "--","bSortable": false},
                    { "data": "mustRebateAmt","defaultContent": "--",sClass: "text-right" ,"bSortable": false},
                    { "data": "mustPremium","defaultContent": "--",sClass: "text-right" ,"bSortable": false},
                    { "data": "realRebateAmt","defaultContent": "--",sClass: "text-right" ,"bSortable": false},
                    { "data": "insureEndDate" ,"defaultContent": "--","bSortable": false},
                    { "data": "salemanName" ,"defaultContent": "--","bSortable": false}

                ],

                "columnDefs" : [{
                    // 定义操作列,######以下是重点########
                    "targets": 26,//是操作按钮目标列
                    "data": null,
                    "render": function (data, type, row) {
                        var id = '"' + row.tid + '"';
                        var html = "";
                        html += "<a  href='#default-tab-3' data-toggle='tab' onclick='showOrderInfo("+row.tid+")'   class='btn-link'>查看详情</a>"
                        return html;
                        /* var id = '"' + row.tid + '"';
                        var html = "";
                        html =  "<a href='javascript:void(0);' onclick='channelShow(\""+ row.insureStartDate + "\","+ row.payInsurerAmt + ","+ row.mustPremium+ ",\""+ row.tid + "\",\""+ row.capitalTid + "\",\""+ row.channelStatus + "\",\""+ row.opponent + "\",\""+ row.tradeType + "\")' class='btn-link'>退保结算</a>&nbsp;&nbsp;&nbsp;&nbsp;"
                        html += "<a href='javascript:void(0);'   onclick='detail("+ id + ")'  class='btn-link'>查看详情</a>"
                        return html;*/
                    }

                },{
                    // 定义操作列,######以下是重点########
                    "targets" : 5,//是操作按钮目标列
                    "data" : null,
                    "render" : function(data, type,row) {
                        var type =  row.typeInsurance;
                        var html = "商业险";
                        if('0'==type){
                            html = "交强险";
                        }
                        return html;
                    }
                },{
                    // 定义操作列,######以下是重点########
                    "targets" : 23,//是操作按钮目标列
                    "data" : null,
                    "render" : function(data, type,row) {
                        var amt1 =  row.mustRebateAmt;
                        var amt2 =  row.mustPremium;
                        if(amt1==null){
                            amt1=0;
                        }
                        if(amt2==null){
                            amt2=0;
                        }
                        var amt = parseFloat(amt2)+parseFloat(amt1);
                        return amt;
                    }
                },{
                    // 定义操作列,######以下是重点########
                    "targets" : 1,//是操作按钮目标列
                    "data" : null,
                    "render" : function(data, type,row) {
                        var type =  ""+row.paySubject;
                        var html = "--";
                        for(var i=0;i<dic.length;i++){
                            var dics = ""+dic[i][0];
                            if(type==dics){
                                html = dic[i][1];
                            }
                        }
                        return html;
                    }
                },{
                    // 定义操作列,######以下是重点########
                    "targets" : 3,//是操作按钮目标列
                    "data" : null,
                    "render" : function(data, type,row) {
                        var type =  row.channelType;
                        var html =  row.channelCName;
                        if('1'==type){
                            html = row.channelPName;
                        }
                        return html;
                    }
                }]

            } );
        } );

            //详情页
            function showOrderInfo(orderId){
                $("#repayTabs li:eq(0)").removeClass("active");
                $("#default-tab-1").removeClass("active in")
                $("#default-tab-2").removeClass("active in")
                $("#repayTabs li:eq(1)").removeClass("active");
                $("#repayTabs li:eq(2)").removeClass("hidden");
                $("#repayTabs li:eq(2)").addClass("active");
                $("#default-tab-3").addClass("active in")

                $("#iframe").attr("src","/ins/order/orderInfoDetail?tid="+orderId);
            }


        function search1(){
            table1.ajax.reload();
        }
        function search2(){
            table2.ajax.reload();
        }

        function openModel(type) {
            $("#typee").val(type);
            if (type==1){
                $("#me").html("确认下载当前列表信息");
            }else if(type==2){
                $("#me").html("确认下载当前列表信息");
            }
            $('#modal-dialog').modal({backdrop: 'static', keyboard: false});
        }

        function doSomeThing() {
            var type = $("#typee").val();
            if(type==1){
                download1s();
            }else if(type==2){
                download2();
            }else{
                table1.ajax.reload();
                table2.ajax.reload();
            }
            $('#modal-dialog').modal('hide')
        }
        function download1s(){
            var insyrerId = $('#insyrerIdSerch').val();
            var ordNum = $('#ordNumSerch').val();
            var channelId = $('#channelIdSerch').val();
            var dateIssuanceStart = $('#dateIssuanceStartSerch').val();
            var dateIssuanceEnd = $('#dateIssuanceEndSerch').val();
            var surrenderDateStart = $('#surrenderDateStartSerch').val();
            var surrenderDateEnd = $('#surrenderDateEndSerch').val();
            window.location.href="<%=path%>/repay/downloadis?capitalStatus=5&insyrerId="+insyrerId+"&ordNum="+ordNum
                +"&channelId="+channelId+"&dateIssuanceStart="+dateIssuanceStart+"&dateIssuanceEnd="+dateIssuanceEnd
                +"&surrenderDateStart="+surrenderDateStart+"&surrenderDateEnd="+surrenderDateEnd;
            /*var tData ={};
             //添加额外的参数传给服务器
             tData.capitalStatus = 1;
             tData.insyrerId = insyrerId;
             tData.ordNum = ordNum;
             tData.channelId = channelId;
             tData.dateIssuanceStart = dateIssuanceStart;
             tData.dateIssuanceEnd = dateIssuanceEnd;
             tData.capitalCreateDateStart = capitalCreateDateStart;
             tData.capitalCreateDateEnd = capitalCreateDateEnd;
             jQuery.ajax({
             type: "POST",
             url: "< %=path%>/repaying/downloadi",
             data:tData,
             success: function (data) {

             }
             });*/
        }
        function download2(){
            var insyrerId = $('#insyrerIdCSerch').val();
            var ordNum = $('#ordNumCSerch').val();
            var channelId = $('#channelIdCSerch').val();
            var dateIssuanceStart = $('#dateIssuanceStartCSerch').val();
            var dateIssuanceEnd = $('#dateIssuanceEndCSerch').val();
            var surrenderDateStart = $('#surrenderDateStartCSerch').val();
            var surrenderDateEnd = $('#surrenderDateEndCSerch').val();
            window.location.href="<%=path%>/repay/downloadc?capitalStatus=5&insyrerId="+insyrerId+"&ordNum="+ordNum
                +"&channelId="+channelId+"&dateIssuanceStart="+dateIssuanceStart+"&dateIssuanceEnd="+dateIssuanceEnd
                +"&surrenderDateStart="+surrenderDateStart+"&surrenderDateEnd="+surrenderDateEnd;
        }

        //改变下载路径
        function changeUrl(type) {
            if(type==2){
                $("#down1").parent().removeClass("hidden");
                $("#down").parent().addClass("hidden");
            }else{
                $("#down").parent().removeClass("hidden");
                $("#down1").parent().addClass("hidden");
            }
        }
            $("#channelNameSerch").keyup(function () {
                var name = $("#channelNameSerch").val();
                if(name!=null&&name!=""){
                    $("#chs").html("");
                    $("#channelIdSerch").val("");
                    $.ajax({
                        url:"/channel/findAllChannelName/"+name,
                        data:{},
                        type:"get",
                        success:function (data) {
                            if(data.success){
                                var channelIds = "";
                                var chHtml = "";
                                for (var i in data.result){
                                    console.log("companyRegisterName--------"+data.result[i].companyRegisterName);

                                    if(data.result[i].companyRegisterName!=null){
                                        chHtml += '<li value='+data.result[i].tid+'>'+data.result[i].companyRegisterName+'</li>';
                                    }else{
                                        chHtml += '<li value='+data.result[i].tid+'>'+data.result[i].contact.name+'</li>';
                                    }
                                    channelIds += "," + data.result[i].tid;
                                }
                                /*var width = parseInt($("#channel").width());*/
                                if(channelIds!=null&&channelIds!=""){
                                    channelIds = channelIds.substring(1,channelIds.length);
                                }else{
                                    channelIds = -1;
                                }
                                $("#chs").html(chHtml);
                                $("#chs").parent().addClass("open");
                                $("#channelIdSerch").val(channelIds);
                                $("#chs li").click(function () {
                                    $("#channelNameSerch").val($(this).html());
                                    $("#channelIdSerch").val($(this).val());
                                })

                            }else{
                                $("#channelIdSerch").val(-1);
                            }
                        },
                        dataType:"json"
                    })
                }else{
                    $("#channelIdSerch").val("");
                    $("#chs li").remove();
                }
            })
            $("#channelNameCSerch").keyup(function () {
                var name = $("#channelNameCSerch").val();
                if(name!=null&&name!=""){
                    $("#chc").html("");
                    $("#channelIdCSerch").val("");
                    $.ajax({
                        url:"/channel/findAllChannelName/"+name,
                        data:{},
                        type:"get",
                        success:function (data) {
                            if(data.success){
                                var channelIds = "";
                                var chHtml = "";
                                for (var i in data.result){
                                    console.log("companyRegisterName--------"+data.result[i].companyRegisterName);

                                    if(data.result[i].companyRegisterName!=null){
                                        chHtml += '<li value='+data.result[i].tid+'>'+data.result[i].companyRegisterName+'</li>';
                                    }else{
                                        chHtml += '<li value='+data.result[i].tid+'>'+data.result[i].contact.name+'</li>';
                                    }
                                    channelIds += "," + data.result[i].tid;
                                }
                                /*var width = parseInt($("#channel").width());*/
                                if(channelIds!=null&&channelIds!=""){
                                    channelIds = channelIds.substring(1,channelIds.length);
                                }else{
                                    channelIds = -1;
                                }
                                $("#chc").html(chHtml);
                                $("#chc").parent().addClass("open");
                                $("#channelIdSerch").val(channelIds);
                                $("#chc li").click(function () {
                                    $("#channelNameCSerch").val($(this).html());
                                    $("#channelIdCSerch").val($(this).val());
                                })

                            }else{
                                $("#channelIdCSerch").val(-1);
                            }
                        },
                        dataType:"json"
                    })
                }else{
                    $("#channelIdCSerch").val("");
                    $("#chs li").remove();
                }
            })
</script>
</body>
</html>
